/**
 * Copyright (C) 2008-2025 isoft Infrastructure Software Co., Ltd.
 * SPDX-License-Identifier: LGPL-2.1-only-with-exception
 *
 * This library is free software; you can redistribute it and/or modify it under the terms of the
 * GNU Lesser General Public License as published by the Free Software Foundation; version 2.1.
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License along with this library;
 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 * or see <https://www.gnu.org/licenses/>.
 */
/*
 ************************************************************************************************************************
 **
 **  @file               : Xcp_GenericType.h
 **  @author             : qinchun.yang
 **  @date               : 2024/11/17
 **  @vendor             : isoft
 **  @description        : Xcp Generic type define
 **
 ***********************************************************************************************************************/

#ifndef XCP_GENERICTYPES_H
#define XCP_GENERICTYPES_H

/* =================================================== inclusions =================================================== */
#include "ComStack_Types.h"

/* ===================================================== macros ===================================================== */
/* Bitmask for Priviledge Level */
#define XCP_PL_CAL  0x01u
#define XCP_PL_DAQ  0x04u
#define XCP_PL_STIM 0x08u
#define XCP_PL_PGM  0x10u

#define XCP_DAQ_STATIC  0u
#define XCP_DAQ_DYNAMIC 1u

#define XCP_TS_NO_TIME_STAMP 0u
#define XCP_TS_ONE_BYTE      1u
#define XCP_TS_TWO_BYTE      2u
#define XCP_TS_FOUR_BYTE     4u

#define XCP_AG_BYTE  0u
#define XCP_AG_WORD  1u
#define XCP_AG_DWORD 2u
/* OVERLOAD */
#define XCP_DAQ_OVL_NO_INDIC 0u
#define XCP_DAQ_OVL_PID      1u
#define XCP_DAQ_OVL_EV       2u

#define XCP_PID_ABSOLUTE              0u
#define XCP_PID_RELATIVE_BYTE         1u
#define XCP_PID_RELATIVE_WORD         2u
#define XCP_PID_RELATIVE_WORD_ALIGNED 3u

typedef uint16 Xcp_CommandStatusType;

#define XCP_CMD_IDLE         (uint16)0
#define XCP_CMD_BLOCK_RECV   0x01U
#define XCP_CMD_RECV         0x02U
#define XCP_CMD_EXECUTE      0x04U
#define XCP_CMD_BLOCK_TRANSF 0x08U
#define XCP_CMD_TRANSF       0x10U

/* Xcp polling mode by short_upload or upload command to get measurement data*/
#define XCP_POLL_MEA_BY_SHORT_UP 0u
#define XCP_POLL_MEA_BY_UP       1u

/* ================================================ type definitions ================================================ */
typedef enum
{
    DAQ      = 1,
    STIM     = 2,
    DAQ_STIM = 3
} Xcp_DaqDirectionType;

typedef enum
{
    XCP_EVENT_CONSIST_ODT,
    XCP_EVENT_CONSIST_DAQ,
    XCP_EVENT_CONSIST_EVENT
} Xcp_EvChConsistType;

typedef enum
{
    TIMESTAMP_UNIT_1NS,
    TIMESTAMP_UNIT_10NS,
    TIMESTAMP_UNIT_100NS,
    TIMESTAMP_UNIT_1US,
    TIMESTAMP_UNIT_10US,
    TIMESTAMP_UNIT_100US,
    TIMESTAMP_UNIT_1MS,
    TIMESTAMP_UNIT_10MS,
    TIMESTAMP_UNIT_100MS,
    TIMESTAMP_UNIT_1S,
    TIMESTAMP_UNIT_1PS,
    TIMESTAMP_UNIT_10PS,
    TIMESTAMP_UNIT_100PS
} XcpTimestampUnitType;

typedef enum
{
    XCP_DAQ_CFG_IDLE,
    XCP_DAQ_CFG_FREE,
    XCP_DAQ_CFG_DAQ,
    XCP_DAQ_CFG_ODT,
    XCP_DAQ_CFG_ENTRY,
    XCP_DAQ_CFG_DONE
} Xcp_DaqCfgStatusType;

typedef enum
{
    XCP_DISCONNECT,
    XCP_PRE_CONNECT,
    XCP_CONNECT,
    XCP_PRE_USERDEFINE,
    XCP_USERDEFINE,
} Xcp_StatusType;

typedef enum
{
    XCP_PRE_SEED,
    XCP_SEED,
    XCP_PRE_KEY,
    XCP_KEY
} Xcp_SeedandKeyStatusType;

typedef struct Xcp_AddressTag
{
    uint8  extensionAddr;
    uint32 transferAddr;
} Xcp_AddressType;

/* ========================================== internal function definitions ========================================= */

/* =========================================== external data declarations =========================================== */

/* ========================================= external function declarations ========================================= */

#endif /* XCP_GENERICTYPES_H */
